import request from '../request/request.js';


// 登录接口
export const login = (data) => {
    return request.post('/login', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//注册接口
export const register = (data) => {
    return request.post('/register', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//搜索商品接口
export const search = (data) => {
    return request.get('/search', {
        params: {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}

//banner接口
export const banner = () => {
    return request.get('/banner', {
        params: {
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}

//商品类型接口
export const type = () => {
    return request.get('/type', {
        params: {
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}

//根据商品类型获取商品接口
export const typeProducts = (data) => {
    return request.get('/typeProducts', {
        params: {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA=',

        }
    })
}

//查看商品详情接口
export const productDetail = (data) => {
    return request.get('/productDetail', {
        params: {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}

//收藏商品接口
export const like = (data) => {
    return request.post('/like', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//取消收藏商品接口
export const notlike = (data) => {
    return request.post('/notlike', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//查询收藏商品接口
export const findlike = (data) => {
    return request.get('/findlike', {
        params: {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}

//查询用户所有收藏商品接口
export const findAllLike = (data) => {
    return request.get('/findAllLike', {
        params: {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}

//添加购物车商品接口
export const addShopcart = (data) => {
    return request.post('/addShopcart', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//查询购物车商品总数量接口
export const shopcartCount = (data) => {
    return request.get('/shopcartCount', {
        params: {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}

//查询用户所有购物车条数接口
export const findAllShopcart = (data) => {
    return request.get('/findAllShopcart', {
        params: {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}

//修改购物车商品数量接口
export const modifyShopcartCount = (data) => {
    return request.post('/modifyShopcartCount', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//删除 一个或者多个 购物车商品接口 该接口为：逻辑删除(假删除，数据仍在数据库中，但不能查询，以便后续客服手动恢复)
export const removeShopcart = (data) => {
    return request.post('/removeShopcart', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//获取购物车商品条目 (不是商品总数量)
export const shopcartRows = (data) => {
    return request.get('/shopcartRows', {
        params: {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}

//新增地址接口
export const addAddress = (data) => {
    return request.post('/addAddress', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//删除地址接口
export const deleteAddress = (data) => {
    return request.post('/deleteAddress', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//查询地址接口
export const findAddress = (data) => {
    return request.get('/findAddress', {
        params: {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}

//编辑地址接口
export const editAddress = (data) => {
    return request.post('/editAddress', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//根据地址aid查询地址接口
export const findAddressByAid = (data) => {
    return request.get('/findAddressByAid', {
        params: {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}


//提交订单页面查询需要购买商品接口
export const commitShopcart = (data) => {
    return request.get('/commitShopcart', {
        params: {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}

//立即结算接口
export const pay = (data) => {
    return request.post('/pay', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

// 查询订单接口
export const findOrder = (data) => {
    return request.get('/findOrder', {
        params: {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}

//  确认收货接口
export const receive = (data) => {
    return request.post('/receive', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//  删除订单接口
export const removeOrder = (data) => {
    return request.post('/removeOrder', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

// 我的接口
export const findMy = (data) => {
    return request.get('/findMy', {
        params: {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}

// 个人资料接口
export const findAccountInfo = (data) => {
    return request.get('/findAccountInfo', {
        params: {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        }
    })
}

//  修改昵称接口
export const updateNickName = (data) => {
    return request.post('/updateNickName', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//  修改简介接口
export const updateDesc = (data) => {
    return request.post('/updateDesc', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//  修改密码接口
export const updatePassword = (data) => {
    return request.post('/updatePassword', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//  退出登录接口
export const logout = (data) => {
    return request.post('/logout', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//  注销账号接口
export const destroyAccount = (data) => {
    return request.post('/destroyAccount', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//  上传头像接口
export const updateAvatar = (data) => {
    return request.post('/updateAvatar', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//  上传用户背景接口
export const updateUserBg = (data) => {
    return request.post('/updateUserBg', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//  获取邮箱验证码接口
export const emailValidCode = (data) => {
    return request.post('/emailValidCode', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}

//  验证码验证接口
export const checkValidCode = (data) => {
        return request.post('/checkValidCode', {
            ...data,
            appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
        })
    }
    //  找回密码接口
export const retrievePassword = (data) => {
    return request.post('/retrievePassword', {
        ...data,
        appkey: 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='
    })
}